/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.ban.news.server.check.checkers;

import cn.ac.iie.di.ban.news.server.check.CheckResult;
import cn.ac.iie.di.ban.news.server.check.Checker;

/**
 *
 * @author zwlin
 */
public class IntegerNonZeroRangeChecker implements Checker<Long, Long> {

    @Override
    public CheckResult check(Long src, Long target) {
        if (src == null) {
            return new CheckResult();
        }
        try {
            if ((target == null || target < 0) && 0 < src) {
                return new CheckResult();
            }
            if (0 < src && src <= target) {
                return new CheckResult();
            } else {
                return new CheckResult("value out of range.");
            }
        } catch (Exception e) {
            return new CheckResult("not int value.");
        }
    }
}
